package com.libcommon

import com.blankj.utilcode.util.FileUtils
import com.blankj.utilcode.util.PathUtils
import com.libcommon.ext.workIO

/**
 * Created on 2022/9/7.
 * @author Joker
 * Des: 全应用本地磁盘使用路径
 */

object GlobalPath {

    /**
     * 根路径
     */
    val ROOT_PATH: String = PathUtils.getInternalAppCachePath()

    /**
     * 创建主数据库文件路径
     */
    fun getObjectBoxDBPath(): String {
        val path = "$ROOT_PATH/objectbox"
        return path
    }

    /**
     * 鲁班压缩文件地址
     */
    fun getLubanTargetPath(): String {
        val path = "$ROOT_PATH/luban/"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * log文件上传路径
     */
    fun getLogPath(): String {
        val path = "$ROOT_PATH/log"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * log文件上传路径
     */
    fun getLogZipPath(): String {
        val path = "$ROOT_PATH/zip"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * mp4本地缓存
     */
    fun getMp4ResPath(): String {
        val path = "$ROOT_PATH/res/mp4"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * svga本地缓存
     */
    fun getSvgaResPath(): String {
        val path = "$ROOT_PATH/res/svga"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * 声网日志
     */
    fun getAgoraLogPath(): String {
        val path = "$ROOT_PATH/agora/log"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * 云信缓存
     */
    fun getNimPath(): String {
        val path = "$ROOT_PATH/nim"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * 临时拍照相册路径
     */
    fun getCameraOutPutPath(): String {
        val path = "${ROOT_PATH}/take_photo"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * 临时裁剪路径
     */
    fun getCropOutPutPath(): String {
        val path = "${ROOT_PATH}/take_photo/crop"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * 录音文件地址
     */
    fun getChatVoicePath(): String {
        val path = "${getNimPath()}/audio"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    /**
     * GIF压缩temp路径
     */
    fun getGifTempPath(): String {
        val path = "${ROOT_PATH}/gif"
        workIO { FileUtils.createOrExistsDir(path) }
        return path
    }

    //游戏缓存目录
    fun getGameWebCache() = "$ROOT_PATH/WebView"

}